using System;
using System.Collections;
using InfoJetSoft.Service.Entity;
using InfoJetSoft.Service.Util;

namespace InfoJetSoft.Service.Worker
{
	/// <summary>
	/// Summary description for SubmitToHostWorker.
	/// </summary>
	class SubmitToHostWorker
	{
		
		public static void submitDoc( Form form, SubmitToHostAdapter submitToHostAdapter )
		{
            //CID 2089 //2014.01.16 //Begin
            if (form.JetContext.HasSubmitToListFormHostEvent())
            {
                form.JetContext.OnSubmitToListFormHostEvent(form, submitToHostAdapter);
            }
            //CID 1134 //2012.03.14 //Begin
            else if (ConfigUtil.EnableSubmitToHostEvent())
            {
                JetIdCache idCache = new JetIdCache(form.XmlDoc.DocumentElement);
                string xml = DOMUtil.toString(form.XmlDoc);
                idCache.reset();
                form.JetContext.OnSubmitToHostEvent(form.Manifest.PublishUrl, xml);
            }
            else
            {
                throw new InfoJetException("Submit to host is not supported in the server side.", "STHW01");
            }
            //CID 1134 //2012.03.20 //End
            //CID 2089 //2014.01.16 //End
		}

	}
}
